package com.project.zsxd.server.sleepInfo.controller;


import com.project.zsxd.server.common.bean.Result;
import com.project.zsxd.server.sleepInfo.entity.SleepInfo;
import com.project.zsxd.server.sleepInfo.service.ISleepInfoService;
import com.project.zsxd.server.user.entity.User;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 早睡打卡统计信息 前端控制器
 * </p>
 *
 * @author kaler
 * @since 2023-02-18
 */
@RestController
@RequestMapping("/sleepInfo")
public class SleepInfoController {

    @Autowired
    private ISleepInfoService sleepInfoService;

    /**
     * 获取用户的打卡统计信息
     * @return 打卡统计信息
     */
    @PostMapping("/get")
    public Result getSleepInfo() {
        User currentUser = (User) SecurityUtils.getSubject().getPrincipal();
        SleepInfo sleepInfo = sleepInfoService.querySleepInfo(currentUser);
        sleepInfo.setId(null);
        sleepInfo.setUserName(null);
        sleepInfo.setStatus(null);
        sleepInfo.setCreatedBy(null);
        sleepInfo.setCreatedTime(null);
        sleepInfo.setUpdatedBy(null);
        sleepInfo.setUpdatedTime(null);
        return Result.success(sleepInfo);
    }

}
